<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class products extends CI_Controller {
	
	function __construct()
	{
		parent::__construct();		
		$this->load->model('products_model','products');
		$this->load->model('home_model','home');
	}
	
	function index()
	{
		$data['title'] = "" ;
		$data['listcat'] = $this->home->get_item_cat();//trit($data['listcat']);
		
		//phan trang
		$config['base_url'] = base_url().'products/index/';
		$config['total_rows'] = $this->products->get_num_product();
		$config['per_page'] = 6;
		$config['uri_segment'] = 3;
		$this->pagination->initialize($config);
		$data['pagination'] = $this->pagination->create_links();
		
		$data['list'] = $this->products->get_product($config['per_page'],(int)$this->uri->segment(3));
		$this->load->view('products',$data) ;
	}
	
	function category()
	{
		$data['title'] = 'Nhóm sản phẩm' ;
		$data['listcat'] = $this->home->get_item_cat();//trit($data['listcat']);

		$catid = (int) $this->uri->segment(3);
		$data['start'] = (int) $this->uri->segment(4);
		$config['base_url'] = base_url().'products/category/'.$catid;  
		$data['num'] = $this->products->count_pro($catid);
		$config['total_rows'] = $data['num'];
		$config['per_page'] = 1;
		$config['uri_segment'] = 4;
		$config['num_links'] = 3 ;
		$this->pagination->initialize($config);   
		$data['pagination'] = $this->pagination->create_links();
		
		$data['list'] = $this->products->get_catid($catid, $config['per_page'], $data['start']);
		$this->load->view('products', $data);
	}
	
}
	

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */